<?php
namespace mob\Model;

use Think\Model;

/**信息模型
 * Class InfoModel
 */
class CacheModel
{


function get($name,$type='File')
{

switch ($type)

{
 case 'File':
 $name=C('CACHE_PREFIX').$name;
 return json_decode(S($name),true) ;
 break;
 case 'Memcache':
 vendor('memcache.MemcacheMod');
 $cache= new \MemcacheMod(C('MEMCACHE_HOST'),C('MEMCACHE_PORT'));
  $name=C('CACHE_PREFIX').$name;
 return json_decode($cache->get($name),true);
 break;

}


}


function set($name,$value,$type='File',$time=3600)
{

switch ($type)

{
 case 'File':
  S(array('type'=>'File','expire'=>$time));
    $name=C('CACHE_PREFIX').$name;
   $value = json_encode($value);
   S($name,$value);


 break;
 case 'Memcache':
  vendor('memcache.MemcacheMod');
  $cache= new \MemcacheMod(C('MEMCACHE_HOST'),C('MEMCACHE_PORT'));
   $name=C('CACHE_PREFIX').$name;
   $value = json_encode($value);
  $cache->set($name,$value,$time);
 break;

}
}



function delete ($name,$type='File')
{

 switch($type)
 {

 case  'File':

$name=C('CACHE_PREFIX').$name;
S($name,null);

 break;


 case 'Memcache':

 vendor('memcache.MemcacheMod');
 $cache= new \MemcacheMod(C('MEMCACHE_HOST'),C('MEMCACHE_PORT'));
  $name=C('CACHE_PREFIX').$name;
 $cache->delete($name);
 break;






 }




}










}